<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout" layout:decorate="body/main">
<head>
    <meta charset="UTF-8">
    <title>客户关系管理系统</title>
</head>
<body>
<div class="right_col" role="main" layout:fragment="content">
    <div class="">
        <div class="clearfix"></div>
        <div class="row">
            <div class="col-md-12">
                <div class="x_panel">
                    <div class="x_title">
                        <h2>
                            客户交往记录 <i class="fa fa-user"></i><small th:text="${session.loginUser.usrName }">用户名</small>
                        </h2>
                        <div class="clearfix"></div>
                    </div>
                    <div class="x_content">
                        <form>
                            <ul>
                                <li>
                                    <div class="form-group">
                                        <label class="control-label col-md-4 col-sm-4 col-xs-12">客户名称</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input name="custName" type="text" class="form-control col-md-7 col-xs-12" th:value="${custName}" readonly>
                                        </div>
                                    </div>
                                </li>
                                <li>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">客户编号</label>
                                        <div class="col-md-7 col-sm-7 col-xs-12">
                                            <input name="custNo" type="text" class="form-control col-md-7 col-xs-12" th:value="${custNo}" readonly>
                                        </div>
                                    </div>
                                </li>
                            </ul>
                        </form>
                    </div>
                </div>
            </div>
            <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                    <div class="x_content">
                        <p class="text-muted font-13 m-b-30"></p>
                        <div id="datatable-responsive_wrapper"
                             class="dataTables_wrapper form-inline dt-bootstrap no-footer">
                            <div class="row">
                                <div class="col-sm-12">
                                    <a th:href="@{/api/customer/findByCustomerList}" class="btn btn-success btn-sm" >返回</a>
                                    <a class="btn btn-success btn-sm" th:href="@{/api/activity/addContactRecords(atvCustNo=${custNo},atvCustName=${custName})}">新增交往记录</a>
                                    <table id="datatable-responsive" class="table table-striped table-bordered dt-responsive nowrap dataTable no-footer dtr-inline collapsed"
                                           cellspacing="0" width="100%" role="grid" aria-describedby="datatable-responsive_info" style="width: 100%;">
                                        <thead>
                                        <tr role="row">
                                            <th class="sorting_asc" tabindex="0"
                                                aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                aria-label="First name: activate to sort column descending"
                                                aria-sort="ascending">时间</th>
                                            <th class="sorting" tabindex="0"
                                                aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                aria-label="Last name: activate to sort column ascending">
                                                地点</th>
                                            <th class="sorting" tabindex="0"
                                                aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                aria-label="Last name: activate to sort column ascending">
                                                概要</th>
                                            <th class="sorting" tabindex="0"
                                                aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                aria-label="Last name: activate to sort column ascending">
                                                详细信息</th>
                                            <th class="sorting" tabindex="0"
                                                aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                aria-label="Last name: activate to sort column ascending">
                                                备注</th>
                                            <th class="sorting" tabindex="0"
                                                aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                aria-label="Last name: activate to sort column ascending">
                                                操作</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr role="row" class="odd" th:each="ctivity,status : ${cstActivityList}">
                                            <td tabindex="0" class="sorting_1" th:text="${#dates.format(ctivity.atvDate,'yyyy-MM-dd HH:mm:ss')}"></td>
                                            <td th:text="${ctivity.atvPlace}"></td>
                                            <td th:text="${ctivity.atvTitle}"></td>
                                            <td th:text="${ctivity.atvDesc}"></td>
                                            <td th:text="${ctivity.atvRemark}"></td>
                                            <td>
                                                <div class="btn-group">
                                                    <button type="button" class="btn btn-danger">点击操作</button>
                                                    <button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                                                        <span class="caret"></span>
                                                        <span class="sr-only">Toggle Dropdown</span>
                                                    </button>
                                                    <ul class="dropdown-menu" role="menu">
                                                        <li>
                                                            <a class="saleSwichOpen" saleSwitch="open" data-toggle="tooltip" data-placement="top" title=""
                                                               th:href="@{/api/activity/getContactRecords(atvId=${ctivity.atvId},custName=${custName})}" >编辑</a>
                                                        </li>
                                                        <li>
                                                            <a class="addVersion" data-toggle="tooltip" data-placement="top" title=""
                                                               href="#"th:onclick="'javascript:doDel(this,'+${ctivity.atvId}+');'">删除</a>
                                                        </li>
                                                    </ul>
                                                </div>
                                            </td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script layout:fragment="js" th:inline="javascript">
    function doDel(obj,atvId){
        if(confirm("你确定要删除该交往信息吗？")){
            $.ajax({
                type:"DELETE",
                url:"/crm/api/activity/deleteContactRecords/"+atvId,
                dataType:"json",
                success:function (data){
                    if(data.result == true){
                        alert("删除成功！");
                        $(obj).parents("tr").remove();
                        // location.reload();
                    }
                },
                error:function (data){
                    alert("对不起，删除失败！");
                }
            })
        }
    }
</script>
</html>